package com.zhihu_lvliangi_android.option.zhengwu;

import com.zhihu_lvliangi_android.R;
import com.zhihu_lvliangi_android.R.id;
import com.zhihu_lvliangi_android.R.layout;
import com.zhihu_lvliangi_android.R.menu;
import com.zhihu_lvliangi_android.domain.PlanModel;
import com.zhihu_lvliangi_android.domain.ZhengwuGuideItem;
import com.zhihu_lvliangi_android.option.parent.ParentActivity;
import com.zhihu_lvliangi_android.util.Constant;

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

/**
 * 评价详情
 * @author 徐宇健
 *
 */
public class EvaluateDetailActivity extends ParentActivity {
	
	private PlanModel mData;
	private LayoutInflater inflater;
	private LinearLayout container;
	private String[] mTitles;
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == android.R.id.home) {
			finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	
	private void initActionBar() {
		ActionBar actionBar = getSupportActionBar();
		actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar));
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setIcon(new BitmapDrawable());//不设置图标icon
		
	}

	
	
	
	@Override
	protected int getLayoutId() {
		return R.layout.activity_progress_detail;
	}

	@Override
	protected void setupViews() {
		initActionBar();
		 inflater = LayoutInflater.from(this);
		 mData = (PlanModel) getIntent().getSerializableExtra(Constant.GENERAL_SAVE_KEY);
		container = (LinearLayout) findViewById(R.id.content_container);
		 mTitles = getResources().getStringArray(R.array.zhengwu_progressitem_title);
		 addView(0,mData.getTitle());
		 addView(1,mData.getThenotifier());
		 addView(2,mData.getCompany());
		 addView(3,mData.getDeclarationdate());
		 addView(4,mData.getCreateDate());
		 addView(5,mData.getUpdateDate());
		 addView(6,mData.getState());
		 addEvaluateView(7,mData.getState());
	}

	private void addEvaluateView(int i, String state) {
		View v = inflater.inflate(R.layout.view_evaluate, null);
		LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
		container.addView(v,i, lp);;
	}

	@Override
	protected void initialized() {
		// TODO Auto-generated method stub
		
	}
	
	private void addView(int i, String src) {
		View v = inflater.inflate(R.layout.activity_affair_detail_item, null);
		TextView title = (TextView) v.findViewById(R.id.item_title);
		TextView content= (TextView) v.findViewById(R.id.item_content);
		title.setText(mTitles[i]);
		if (!TextUtils.isEmpty(src.trim())) {
			content.setText(src);
		}else {
			content.setText("暂无信息");
		}
		
		LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
		container.addView(v,i, lp);;
	}
	
	@Override
	protected void threadTask() {
		// TODO Auto-generated method stub
		
	}
}
